home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / TABSIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  7.6 KB  |  295 lines

  1. unit TabSImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib, Tabs;
  8.  
  9. type
  10.   TTabSetX = class(TActiveXControl, ITabSetX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TTabSet;
  14.     FEvents: ITabSetXEvents;
  15.     procedure ChangeEvent(Sender: TObject; NewTab: Integer;
  16.       var AllowChange: Boolean);
  17.     procedure ClickEvent(Sender: TObject);
  18.     procedure MeasureTabEvent(Sender: TObject; Index: Integer;
  19.       var TabWidth: Integer);
  20.   protected
  21.     { Protected declarations }
  22.     procedure InitializeControl; override;
  23.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  24.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  25.     function Get_AutoScroll: WordBool; safecall;
  26.     function Get_BackgroundColor: TColor; safecall;
  27.     function Get_Cursor: Smallint; safecall;
  28.     function Get_DitherBackground: WordBool; safecall;
  29.     function Get_Enabled: WordBool; safecall;
  30.     function Get_EndMargin: Integer; safecall;
  31.     function Get_FirstIndex: Integer; safecall;
  32.     function Get_Font: Font; safecall;
  33.     function Get_SelectedColor: TColor; safecall;
  34.     function Get_StartMargin: Integer; safecall;
  35.     function Get_Style: TxTabStyle; safecall;
  36.     function Get_TabHeight: Integer; safecall;
  37.     function Get_TabIndex: Integer; safecall;
  38.     function Get_Tabs: IStrings; safecall;
  39.     function Get_UnselectedColor: TColor; safecall;
  40.     function Get_Visible: WordBool; safecall;
  41.     function Get_VisibleTabs: Integer; safecall;
  42.     procedure AboutBox; safecall;
  43.     procedure SelectNext(Direction: WordBool); safecall;
  44.     procedure Set_AutoScroll(Value: WordBool); safecall;
  45.     procedure Set_BackgroundColor(Value: TColor); safecall;
  46.     procedure Set_Cursor(Value: Smallint); safecall;
  47.     procedure Set_DitherBackground(Value: WordBool); safecall;
  48.     procedure Set_Enabled(Value: WordBool); safecall;
  49.     procedure Set_EndMargin(Value: Integer); safecall;
  50.     procedure Set_FirstIndex(Value: Integer); safecall;
  51.     procedure Set_Font(const Value: Font); safecall;
  52.     procedure Set_SelectedColor(Value: TColor); safecall;
  53.     procedure Set_StartMargin(Value: Integer); safecall;
  54.     procedure Set_Style(Value: TxTabStyle); safecall;
  55.     procedure Set_TabHeight(Value: Integer); safecall;
  56.     procedure Set_TabIndex(Value: Integer); safecall;
  57.     procedure Set_Tabs(const Value: IStrings); safecall;
  58.     procedure Set_UnselectedColor(Value: TColor); safecall;
  59.     procedure Set_Visible(Value: WordBool); safecall;
  60.   end;
  61.  
  62. implementation
  63. uses TabSPg;
  64. { TTabSetX }
  65.  
  66. procedure TTabSetX.InitializeControl;
  67. begin
  68.   FDelphiControl := Control as TTabSet;
  69.   FDelphiControl.OnChange := ChangeEvent;
  70.   FDelphiControl.OnClick := ClickEvent;
  71.   FDelphiControl.OnMeasureTab := MeasureTabEvent;
  72. end;
  73.  
  74. procedure TTabSetX.EventSinkChanged(const EventSink: IUnknown);
  75. begin
  76.   FEvents := EventSink as ITabSetXEvents;
  77. end;
  78.  
  79. procedure TTabSetX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  80. begin
  81.   { Define property pages here.  Property pages are defined by calling
  82.     DefinePropertyPage with the class id of the page.  For example,
  83.       DefinePropertyPage(Class_TabSetXPage); }
  84. end;
  85.  
  86. function TTabSetX.Get_AutoScroll: WordBool;
  87. begin
  88.   Result := FDelphiControl.AutoScroll;
  89. end;
  90.  
  91. function TTabSetX.Get_BackgroundColor: TColor;
  92. begin
  93.   Result := FDelphiControl.BackgroundColor;
  94. end;
  95.  
  96. function TTabSetX.Get_Cursor: Smallint;
  97. begin
  98.   Result := Smallint(FDelphiControl.Cursor);
  99. end;
  100.  
  101. function TTabSetX.Get_DitherBackground: WordBool;
  102. begin
  103.   Result := FDelphiControl.DitherBackground;
  104. end;
  105.  
  106. function TTabSetX.Get_Enabled: WordBool;
  107. begin
  108.   Result := FDelphiControl.Enabled;
  109. end;
  110.  
  111. function TTabSetX.Get_EndMargin: Integer;
  112. begin
  113.   Result := FDelphiControl.EndMargin;
  114. end;
  115.  
  116. function TTabSetX.Get_FirstIndex: Integer;
  117. begin
  118.   Result := FDelphiControl.FirstIndex;
  119. end;
  120.  
  121. function TTabSetX.Get_Font: Font;
  122. begin
  123.   GetOleFont(FDelphiControl.Font, Result);
  124. end;
  125.  
  126. function TTabSetX.Get_SelectedColor: TColor;
  127. begin
  128.   Result := FDelphiControl.SelectedColor;
  129. end;
  130.  
  131. function TTabSetX.Get_StartMargin: Integer;
  132. begin
  133.   Result := FDelphiControl.StartMargin;
  134. end;
  135.  
  136. function TTabSetX.Get_Style: TxTabStyle;
  137. begin
  138.   Result := Ord(FDelphiControl.Style);
  139. end;
  140.  
  141. function TTabSetX.Get_TabHeight: Integer;
  142. begin
  143.   Result := FDelphiControl.TabHeight;
  144. end;
  145.  
  146. function TTabSetX.Get_TabIndex: Integer;
  147. begin
  148.   Result := FDelphiControl.TabIndex;
  149. end;
  150.  
  151. function TTabSetX.Get_Tabs: IStrings;
  152. begin
  153.   GetOleStrings(FDelphiControl.Tabs, Result);
  154. end;
  155.  
  156. function TTabSetX.Get_UnselectedColor: TColor;
  157. begin
  158.   Result := FDelphiControl.UnselectedColor;
  159. end;
  160.  
  161. function TTabSetX.Get_Visible: WordBool;
  162. begin
  163.   Result := FDelphiControl.Visible;
  164. end;
  165.  
  166. function TTabSetX.Get_VisibleTabs: Integer;
  167. begin
  168.   Result := FDelphiControl.VisibleTabs;
  169. end;
  170.  
  171. procedure TTabSetX.AboutBox;
  172. begin
  173.   ShowTabSetXAbout;
  174. end;
  175.  
  176. procedure TTabSetX.SelectNext(Direction: WordBool);
  177. begin
  178.  
  179. end;
  180.  
  181. procedure TTabSetX.Set_AutoScroll(Value: WordBool);
  182. begin
  183.   FDelphiControl.AutoScroll := Value;
  184. end;
  185.  
  186. procedure TTabSetX.Set_BackgroundColor(Value: TColor);
  187. begin
  188.   FDelphiControl.BackgroundColor := Value;
  189. end;
  190.  
  191. procedure TTabSetX.Set_Cursor(Value: Smallint);
  192. begin
  193.   FDelphiControl.Cursor := TCursor(Value);
  194. end;
  195.  
  196. procedure TTabSetX.Set_DitherBackground(Value: WordBool);
  197. begin
  198.   FDelphiControl.DitherBackground := Value;
  199. end;
  200.  
  201. procedure TTabSetX.Set_Enabled(Value: WordBool);
  202. begin
  203.   FDelphiControl.Enabled := Value;
  204. end;
  205.  
  206. procedure TTabSetX.Set_EndMargin(Value: Integer);
  207. begin
  208.   FDelphiControl.EndMargin := Value;
  209. end;
  210.  
  211. procedure TTabSetX.Set_FirstIndex(Value: Integer);
  212. begin
  213.   FDelphiControl.FirstIndex := Value;
  214. end;
  215.  
  216. procedure TTabSetX.Set_Font(const Value: Font);
  217. begin
  218.   SetOleFont(FDelphiControl.Font, Value);
  219. end;
  220.  
  221. procedure TTabSetX.Set_SelectedColor(Value: TColor);
  222. begin
  223.   FDelphiControl.SelectedColor := Value;
  224. end;
  225.  
  226. procedure TTabSetX.Set_StartMargin(Value: Integer);
  227. begin
  228.   FDelphiControl.StartMargin := Value;
  229. end;
  230.  
  231. procedure TTabSetX.Set_Style(Value: TxTabStyle);
  232. begin
  233.   FDelphiControl.Style := TTabStyle(Value);
  234. end;
  235.  
  236. procedure TTabSetX.Set_TabHeight(Value: Integer);
  237. begin
  238.   FDelphiControl.TabHeight := Value;
  239. end;
  240.  
  241. procedure TTabSetX.Set_TabIndex(Value: Integer);
  242. begin
  243.   FDelphiControl.TabIndex := Value;
  244. end;
  245.  
  246. procedure TTabSetX.Set_Tabs(const Value: IStrings);
  247. begin
  248.   SetOleStrings(FDelphiControl.Tabs, Value);
  249. end;
  250.  
  251. procedure TTabSetX.Set_UnselectedColor(Value: TColor);
  252. begin
  253.   FDelphiControl.UnselectedColor := Value;
  254. end;
  255.  
  256. procedure TTabSetX.Set_Visible(Value: WordBool);
  257. begin
  258.   FDelphiControl.Visible := Value;
  259. end;
  260.  
  261. procedure TTabSetX.ChangeEvent(Sender: TObject; NewTab: Integer;
  262.   var AllowChange: Boolean);
  263. var
  264.   TempAllowChange: WordBool;
  265. begin
  266.   TempAllowChange := WordBool(AllowChange);
  267.   if FEvents <> nil then FEvents.OnChange(NewTab, TempAllowChange);
  268.   AllowChange := Boolean(TempAllowChange);
  269. end;
  270.  
  271. procedure TTabSetX.ClickEvent(Sender: TObject);
  272. begin
  273.   if FEvents <> nil then FEvents.OnClick;
  274. end;
  275.  
  276. procedure TTabSetX.MeasureTabEvent(Sender: TObject; Index: Integer;
  277.   var TabWidth: Integer);
  278. var
  279.   TempTabWidth: Integer;
  280. begin
  281.   TempTabWidth := Integer(TabWidth);
  282.   if FEvents <> nil then FEvents.OnMeasureTab(Index, TempTabWidth);
  283.   TabWidth := Integer(TempTabWidth);
  284. end;
  285.  
  286. initialization
  287.   TActiveXControlFactory.Create(
  288.     ComServer,
  289.     TTabSetX,
  290.     TTabSet,
  291.     Class_TabSetX,
  292.     27,
  293.     '{5A5659DB-7975-11D0-BE02-00A024D1875C}');
  294. end.
  295.